using System.Collections.Generic;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Newtonsoft.Json;
using YacGE.Map;

namespace YacGE
{
#if WINDOWS || XBOX
    internal static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        private static void Main(string[] args)
        {
            using (var game = new Game())
            {
                //var mapObject = new MapObject()
                //                          {
                //                              EventFunctionNameList = new Dictionary<string, List<string>>(),
                //                              EventRecognitionFunctionNameList = new Dictionary<string, string>(),
                //                              InputFunctionNameList = new Dictionary<Keys, List<string>>(),
                //                              ObjectName = "TestObject",
                //                              Position = new Vector2(0, 0),
                //                              Properties = new Dictionary<string, object>(),
                //                              RenderImageLocation = "test.png",
                //                              Size = new Vector2(0, 0),
                //                              UpdateFunctionNameList = new List<string>(),
                //                              Velocity = new Vector2(0, 0)
                //                          };


                //mapObject.EventFunctionNameList.Add("OnTest", new List<string>());
                //mapObject.EventFunctionNameList["OnTest"].Add("eventtestfunc");

                //mapObject.EventRecognitionFunctionNameList.Add("OnTest", "eventtestrecognition");

                //mapObject.InputFunctionNameList.Add(Keys.W, new List<string>());
                //mapObject.InputFunctionNameList[Keys.W].Add("onWPressed");

                //mapObject.UpdateFunctionNameList.Add("updatecall");

                ////var jsonMapObject = JsonConvert.SerializeObject(mapObject);

                //var mapLoadingHelper = new MapLoadingHelper
                //                           {
                //                               MapObjects = new MapObject[] { mapObject },
                //                               PythonScriptFiles = new string[] { @"testmap.pyscr" }
                //                           };

                //TextReader textReader = new StreamReader("test.py");

                //string temp = null;
                //var temp2 = new List<string>();
                //while ((temp = textReader.ReadLine()) != null)
                //{
                //    temp2.Add(temp);
                //}

                //textReader.Close();

                //var scriptLoadingHelper = new ScriptLoadingHelper()
                //                                              {
                //                                                  FunctionNameList =
                //                                                      new string[]
                //                                                          {
                //                                                              "eventtestfunc", "eventtestrecognition",
                //                                                              "onWPressed", "updatecall"
                //                                                          },
                //                                                  PythonSource =
                //                                                      String.Join(Environment.NewLine, temp2.ToArray())
                //                                              };

                //string jsonMapLoadingHelper = JsonConvert.SerializeObject(mapLoadingHelper);

                //TextWriter textWriter = new StreamWriter("testmap.yamap");

                //textWriter.Write(jsonMapLoadingHelper);

                //textWriter.Close();

                game.Run();
            }
        }
    }
#endif
}